<template>
  <el-table
    highlight-current-row
    ref="multipleTable"
    :data="tableDataList"
    tooltip-effect="dark"
    style="width: 100%"
  >
    <!-- <el-table-column type="selection" width="55"></el-table-column> -->
    <el-table-column type="index" label="序号" width="65"></el-table-column>
    <el-table-column prop="orderNo" label="订单编号" width="250px"></el-table-column>
    <el-table-column prop="skuName" label="商品名称" width="120px"></el-table-column>
    <el-table-column prop="price" label="订单金额(元)" show-overflow-tooltip></el-table-column>
    <el-table-column prop="innerCode" label="设备编号" show-overflow-tooltip></el-table-column>
    <el-table-column prop="status" label="订单状态" :formatter="formatterFn" show-overflow-tooltip></el-table-column>
    <el-table-column prop="createTime" label="订单日期" show-overflow-tooltip></el-table-column>
    <el-table-column label="操作">
      <template #default="{row}">
        <el-button type="text" @click="openasdf(row)">查看详情</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import moment from 'moment'
// 引入枚举
import vm from '@/Enums/vm'
export default {
  name: 'EmperorKedeOrderbody',
  props: {
    tableData: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {
      tableDataList: [],
      formatdingdan: vm.thisdingdanguanli
    }
  },

  watch: {
    tableData (newval) {
      // console.log(this.tableDataList)
      this.tableDataList = newval
      // console.log(this.tableDataList)
      // const arr1 =
      this.tableDataList.map((item) => {
        // return console.log(item)
        return (item.price = item.price.toFixed(2))
      })
      // console.log(arr1)
      // const arr2 =
      this.tableDataList.map((item) => {
        // return console.log(item)
        return (item.createTime = moment(item.createTime).format(
          'YYYY.MM.DD HH:mm:ss'
        ))
      })
      // console.log(arr2)
    }
  },
  mounted () {
    // console.log(this.tableDataList)
    // console.log(this.formatdingdan)
  },
  methods: {
    formatterFn (row, column, cellValue, index) {
      //  console.log('cellValue'，cellValue) // 聘用形式
      // cellValue 0，1
      // You，1 second ago
      // [{id: 1，value:正式'}，[J]
      // 把拿到的数据进行遍历查找
      const info = this.formatdingdan.find((item) => item.id === cellValue)
      // .find 返回的是 一个对象
      // 处理方法 判断 info 有没有数据  只有有数据 才渲染
      return (info && info.value) || '阿巴巴'
    },
    //
    openasdf (row) {
      this.$emit('openasdf', row)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
